/* GUI CONVERTED from sqqorp02.p (converter v1.76) Wed Jul 10 23:13:57 2002 */
/* sqqorp02.p - QUOTE REPORT BY ITEM                                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.13 $                                                               */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 4.0     LAST MODIFIED: 12/12/88   BY: jms  *A548*                */
/* REVISION: 5.0     LAST MODIFIED: 03/21/89   BY: RL   *B051*                */
/* REVISION: 6.0     LAST MODIFIED: 04/20/90   BY: ftb *                      */
/* REVISION: 6.0     LAST MODIFIED: 04/09/91   BY: bjb  *D625*                */
/* REVISION: 7.0     LAST MODIFIED: 03/27/92   BY: dld  *F326*                */
/* REVISION: 7.0     LAST MODIFIED: 06/08/92   BY: afs *F586*                 */
/* REVISION: 7.3     LAST MODIFIED: 01/13/94   BY: dpm *FL32*                 */
/* REVISION: 7.3     LAST MODIFIED: 06/03/94   BY: dpm *GK08*                 */
/* REVISION: 8.5     LAST MODIFIED: 09/12/95   BY: taf *J053*                 */
/* REVISION: 8.5     LAST MODIFIED: 04/09/96   BY: jzw *G1P6*                 */
/* REVISION: 8.5     LAST MODIFIED: 07/17/96   BY: taf *J0ZH*                 */
/* REVISION: 8.6     LAST MODIFIED: 10/06/97   BY: mzv *K0LK*                 */
/* REVISION: 8.6E    LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane           */
/* REVISION: 8.6E    LAST MODIFIED: 06/11/98   BY: *L02K* Russ Witt           */
/* REVISION: 8.6E    LAST MODIFIED: 08/07/98   BY: *L05K* Russ Witt           */
/* REVISION: 9.1     LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane    */
/* REVISION: 9.1     LAST MODIFIED: 08/12/00   BY: *N0KN* Mark Brown          */
/* REVISION: 9.1     LAST MODIFIED: 11/20/00   BY: *N0TW* Jean Miller         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.13 $      BY: Hareesh V             DATE: 06/21/02  ECO: *N1HY*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define variable rndmthd         like rnd_rnd_mthd                   no-undo.
define variable oldcurr         like qo_curr                        no-undo.
define variable part            like qod_part                       no-undo.
define variable part1           like qod_part                       no-undo.
define variable nbr             like qo_nbr                         no-undo.
define variable nbr1            like qo_nbr                         no-undo.
define variable slspsn          as   character format "x(8)"
                                label "Salesperson"                 no-undo.
define variable slspsn1         like slspsn                         no-undo.
define variable ord             like qo_ord_date                    no-undo.
define variable ord1            like qo_ord_date                    no-undo.
define variable site            like qod_site                       no-undo.
define variable site1           like qod_site                       no-undo.
define variable name            like ad_name   format "x(18)"       no-undo.
define variable desc1           like pt_desc1                       no-undo.
define variable expdate         like qo_exp_date                    no-undo.
define variable expdate1        like qo_exp_date                    no-undo.
define variable ext_price       like qod_price label "Ext Price"
                                format "->,>>>,>>>,>>9.99<<<"       no-undo.
define variable base_price      like qod_price                      no-undo.
define variable base_rpt        like so_curr                        no-undo.
define variable disp_curr       as   character format "x(1)"
                                label "C"                           no-undo.
define variable mc-error-number like msg_nbr                        no-undo.
define variable disp-text       as   character format "x(15)"       no-undo.

/* DATA DEFINITIONS FOR TRIANGULATION LIBRARY ROUTINES */
{gprunpdf.i "mcpl" "p"}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
part      colon 20  part1     label "To" colon 49
   nbr       colon 20  nbr1      label "To" colon 49
   slspsn    colon 20  slspsn1   label "To" colon 49
   ord       colon 20  ord1      label "To" colon 49
   expdate   colon 20  expdate1  label "To" colon 49
   site      colon 20  site1     label "To" colon 49 skip(1)
   base_rpt  colon 25
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

find first gl_ctrl no-lock.

oldcurr = "".
{wbrp01.i}

/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if part1 = hi_char
   then
      part1 = "".

   if nbr1 = hi_char
   then
      nbr1 = "".

   if slspsn1 = hi_char
   then
      slspsn1 = "".

   if ord = low_date
   then
      ord = ?.

   if ord1 = hi_date
   then
      ord1 = ?.

   if expdate = low_date
   then
      expdate = ?.

   if expdate1 = hi_date
   then
      expdate1 = ?.

   if site1 = hi_char
   then
      site1 = "".

   if c-application-mode <> 'WEB'
   then
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update
             &fields = "  part     part1
                          nbr      nbr1
                          slspsn   slspsn1
                          ord      ord1
                          expdate  expdate1
                          site     site1
                          base_rpt"
             &frm = "a"}

   if     (c-application-mode <> 'WEB')
      or  (c-application-mode  = 'WEB'
      and (c-web-request begins 'DATA'))
   then do:

      /* CREATE BATCH INPUT STRING */
      bcdparm = "".
      {mfquoter.i part     }
      {mfquoter.i part1    }
      {mfquoter.i nbr      }
      {mfquoter.i nbr1     }
      {mfquoter.i slspsn   }
      {mfquoter.i slspsn1  }
      {mfquoter.i ord      }
      {mfquoter.i ord1     }
      {mfquoter.i expdate  }
      {mfquoter.i expdate1 }
      {mfquoter.i site     }
      {mfquoter.i site1    }
      {mfquoter.i base_rpt }

      if part1 = ""
      then
         part1 = hi_char.

      if nbr1 = ""
      then
         nbr1 = hi_char.

      if slspsn1 = ""
      then
         slspsn1 = hi_char.

      if ord = ?
      then
         ord = low_date.

      if ord1 = ?
      then
         ord1 = hi_date.

      if expdate = ?
      then
         expdate = low_date.

      if expdate1 = ?
      then
         expdate1 = hi_date.

      if site1 = ""
      then
         site1 = hi_char.
   end. /* IF (c-application-mode <> 'WEB').... */

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:
find first gl_ctrl no-lock.




   {mfphead.i}

   FORM /*GUI*/  header
      skip(1)
   with STREAM-IO /*GUI*/  frame p1 page-top width 132.
   view frame p1.

	{hksimsg.i site site1}      /*fdn*/

   /* GET QUOTE DETAIL  */
   for each qod_det
      fields (qod_desc      qod_line
              qod_nbr       qod_part
              qod_price     qod_qty_quot
              qod_qty_rel   qod_rel_chg
              qod_site      qod_um
              qod_um_conv)
      where qod_part >= part and qod_part <= part1
      and   qod_nbr  >= nbr  and qod_nbr  <= nbr1
      and   qod_site >= site and qod_site <= site1 AND LOOKUP(qod_site, GLOBAL_user_site) > 0 ,     /*fdn*/
      each qo_mstr
         fields (qo_curr     qo_cust
                 qo_exp_date qo_ex_rate
                 qo_ex_rate2 qo_nbr
                 qo_ord_date qo_slspsn)
         where qo_nbr        = qod_nbr
         and   qo_ord_date  >= ord     and qo_ord_date  <= ord1
         and   qo_exp_date  >= expdate and qo_exp_date  <= expdate1
         and ((qo_slspsn[1] >= slspsn  and qo_slspsn[1] <= slspsn1)
         or   (qo_slspsn[2] >= slspsn  and qo_slspsn[2] <= slspsn1)
         or   (qo_slspsn[3] >= slspsn  and qo_slspsn[3] <= slspsn1)
         or   (qo_slspsn[4] >= slspsn  and qo_slspsn[4] <= slspsn1))
         and  (base_rpt = ""
         or    qo_curr = base_rpt) 
         no-lock
         break by qod_part
               by qo_ord_date
      with frame f-a width 132 no-box no-attr-space:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame f-a:handle).

      if    (oldcurr <> qo_curr)
         or (oldcurr = "")
      then do:

         if qo_curr = gl_base_curr
         then
            rndmthd = gl_rnd_mthd.
         else do:
            /* GET ROUNDING METHOD FROM CURRENCY MASTER */
            {gprunp.i "mcpl" "p" "mc-get-rnd-mthd"
               "(input qo_curr,
                 output rndmthd,
                 output mc-error-number)"}
            if mc-error-number <> 0
            then do:
               {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
               if c-application-mode <> "WEB"
               then
                  leave.
               pause.
            end. /* IF mc-error-number <> 0 */
         end. /* ELSE DO */

         oldcurr = qo_curr.
      end. /* IF (oldcurr <> qo_curr) */

      assign
         base_price  = qod_price
         ext_price   = qod_rel_chg * base_price
         disp_curr   = "".

      if base_curr <> qo_curr
         and base_rpt = ""
      then do:

         /* CONVERT FROM FOREIGN TO BASE CURRENCY */
         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input qo_curr,
              input base_curr,
              input qo_ex_rate,
              input qo_ex_rate2,
              input base_price,
              input false, /* DO NOT ROUND */
              output base_price,
              output mc-error-number)"}.

         /* CALCULATE BASE EXTENDED USING QO_EX_RATE */

         /* CONVERT FROM FOREIGN TO BASE CURRENCY */
         {gprunp.i "mcpl" "p" "mc-curr-conv"
            "(input qo_curr,
              input base_curr,
              input qo_ex_rate,
              input qo_ex_rate2,
              input ext_price,
              input false, /* DO NOT ROUND */
              output ext_price,
              output mc-error-number)"}.
         if mc-error-number <> 0
         then do:
            {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
            leave.
         end. /* IF mc-error-number <> 0 */

         disp_curr = getTermLabel("YES",1).
      end. /* IF base_curr <> qo_curr...*/

      /* ROUND BASE_PRICE USING BASE CURRENCY */
      {gprunp.i "mcpl" "p" "mc-curr-rnd"
         "(input-output base_price,
           input        rndmthd,
           output       mc-error-number)"}
      if mc-error-number <> 0
      then do:
         {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         leave.
      end. /* IF mc-error-number <> 0 */

      /* ROUND EXTENDED USING DOC CURRENCY */
      {gprunp.i "mcpl" "p" "mc-curr-rnd"
         "(input-output ext_price,
           input        rndmthd,
           output       mc-error-number)"}

      if mc-error-number <> 0
      then do:
         {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
         leave.
      end. /* IF mc-error-number <> 0 */

      name = "".

      for first ad_mstr
         fields (ad_addr ad_name)
         where ad_addr = qo_cust
         no-lock:
         name = ad_name.
      end. /* FOR FIRST ad_mstr */

      desc1 = "".

      for first pt_mstr
         fields (pt_desc1 pt_desc2 pt_part)
         where pt_part = qod_part
         no-lock:
      end. /* FOR FIRST pt_mstr */

      if available pt_mstr
      then
         desc1 = pt_desc1 + " " + pt_desc2.
      else
         desc1 = qod_desc.

      if first-of(qod_part)
      then do:
         if page-size - line-counter < 5
         then
            page.
         display with no-attr-space width 132 STREAM-IO /*GUI*/ .
         put
            {gplblfmt.i &FUNC=getTermLabel(""ITEM"",7) &CONCAT="': '"}
            qod_part
            " "
            desc1 format "x(49)" skip(1).
      end. /* IF FIRST-OF(qod_part) */

      display
         qo_nbr
         qo_cust
         name
         qod_line
         qod_qty_quot format "->>>>>>9.9<<<<"
         qod_qty_rel
         qod_rel_chg  format "->>>>>>9.9<<<<"
         qod_um
         disp_curr
         base_price
         ext_price
         qo_ord_date
         qo_exp_date
      with no-box no-attr-space width 132 STREAM-IO /*GUI*/ .

      accumulate qod_qty_quot * qod_um_conv (total by qod_part).
      accumulate qod_qty_rel  * qod_um_conv (total by qod_part).
      accumulate qod_rel_chg  * qod_um_conv (total by qod_part).
      accumulate ext_price (total by qod_part).

      if last-of(qod_part)
      then do:
         down 1.
         if page-size - line-counter < 2
         then
            page.
         underline  qod_qty_quot qod_qty_rel qod_rel_chg ext_price.
         down 1.
         display
            accum total by qod_part qod_qty_quot * qod_um_conv
            @ qod_qty_quot
            accum total by qod_part qod_qty_rel  * qod_um_conv
            @ qod_qty_rel
            accum total by qod_part qod_rel_chg  * qod_um_conv
            @ qod_rel_chg
            accum total by qod_part ext_price @ ext_price WITH STREAM-IO /*GUI*/ .

         if last(qod_part)
         then do:
            if page-size - line-counter < 3
            then
               page.
            underline ext_price.
            down 1.
            if base_rpt = ""
            then
               disp-text = getTermLabel("BASE_TOTAL",14) + ":".
            else
               disp-text = base_rpt + " " + getTermLabel("TOTAL",10) + ":".

            display
               disp-text format "x(15)" @ base_price
               accum total ext_price    @ ext_price WITH STREAM-IO /*GUI*/ .
         end. /* IF LAST(qod_part) */

      end. /* IF LAST-OF(qod_part) */

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end. /* FOR EACH qod_det .. */

   /* REPORT TRAILER  */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end. /* REPEAT */

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 nbr nbr1 slspsn slspsn1 ord ord1 expdate expdate1 site site1 base_rpt "} /*Drive the Report*/
